﻿@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList.Mvc.Common;
@using FwProject.Car.Dto
@model IPagedList<CarInfoDto>
@{
    Layout = null;
    int i = 0;
    if (Model.Count > 0)
    {
        if (Model.PageNumber != 1)
        {

            i = (Model.PageNumber - 1) * Model.PageSize;
        }
    }
}
<div style="max-height:600px;overflow-y:scroll;">

    <table class="table table-bordered table-hover table-rowselected">
        <thead>
            <tr>
                <th style="width:45px">序号</th>
                <th>汽车司机</th>
                <th>车牌号码</th>
                <th>汽车类型</th>
                <th>吨位（T）</th>
                <th>购买时间</th>
                <th>是否购买保险</th>
                <th style="width:120px;">操作</th>
            </tr>
        </thead>
        <tbody>
            @if (Model.Count == 0)
            {
                <tr><td class="text-center" colspan="8">暂无工厂车辆信息</td></tr>
            }
            else
            {
                foreach (var item in Model)
                {
                    i++;
                    <tr>
                        <td>@i</td>
                        <td>@item.CarUser.Name</td>
                        <td>@item.PlatesNumber</td>
                        <td>@item.CarType</td>
                        <td>@item.ShoppingTon</td>
                        <td>@item.CarOld.ToString("yyyy-MM-dd")</td>
                        <td>@(item.Insurance ? "已购买" : "未购买")</td>
                        <td>
                            <button class="btn btn-success btn-xs" data-toggle="modal" data-target="#modal_ajax" data-backdrop="static" data-url="@Url.Action("Edit", new { id = item.Id })"><i class="fa fa-edit"></i>编辑</button>
                            <button class="btn btn-danger btn-xs" data-toggle="modal" data-target="#modal_del" data-url="@Url.Action("DeleteCar", new { id = item.Id })"><i class="fa fa-times"></i>删除</button>
                        </td>
                    </tr>
                }
            }
        </tbody>
    </table>
</div>
<div class="row pagedinfo">
    <div class="col-sm-5">
        @*共 @Model.TotalItemCount 条，@Model.PageSize 条/页 当前第 @Model.PageNumber/@Model.PageCount 页*@
        共 @Model.TotalItemCount 条，
        <select class="form-control" id="pageSize" style="width:70px;display:initial">
            @for (int z = 10; z < 100; z = z + 10)
            {
                if (z == Model.PageSize)
                {
                    <option selected value="@z">@z</option>
                }
                else
                {
                    <option value="@z">@z</option>
                }
            }
        </select> &nbsp;条/页 当前第 @Model.PageNumber/@Model.PageCount 页
    </div>
    <div class="col-sm-7">
        <input type="hidden" id="pageurl" value="&keyword=@(Context.Request.Query["keyword"])&factoryid=@(Context.Request.Query["factoryid"])" />
        @Html.PagedListPager(Model, page => Url.Action("Index", new { pageIdx = page,size= Context.Request.Query["size"], keyword = Context.Request.Query["keyword"], factoryid = Context.Request.Query["factoryid"] }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { AllowCache = false, HttpMethod = "Get", UpdateTargetId = "data_list", OnSuccess = "AjaxSuccessCallback", OnBegin = "AjaxBegin" }))
    </div>
</div>
